<template>
  <div>
    <ParkingInquire @parentsearch="parentsearch" @resettable="resettable"></ParkingInquire>

    <Rarkingform :arr="arr" @initHome="initHome"></Rarkingform>
    <Parkingpage @changePageSize="parentpagesize" @changePage="parentpage" :pageSize="pageSize" @page="page"
      :total="total"></Parkingpage>
  </div>
</template>
<script>
import ParkingInquire from './components/ParkingInquire.vue'
import Rarkingform from './components/Rarkingform.vue'
import Parkingpage from './components/Parkingpage.vue'
import { getHomeApi , addFunApi} from '../../api/ParkingApi.js'
export default {
  data() {
    return {
      arr: [],
      keyword: '',//搜索关键词
      page: 1,//默认当前页 是第一页
      pageSize: 50,//默认每页显示20条
      total: 0,//总条数
      show: false,//控制弹框
      row: {},//修改的弹框数据
      dialogType: 0 //0添加的框  1修改的弹框 
    }
  },
  components: {
    ParkingInquire,
    Rarkingform,
    Parkingpage,
  },
  mounted() {
    // 发送我们的请求，数组是共享数据，我们要把写在父组件中。
    this.initHome()
  },
  methods: {
    parentpagesize(val) {
      this.pageSize = val
      this.initHome()
    },
    parentpage(val) {
      this.page = val
      this.initHome()
    },
    parentsearch(val) {
      //搜索子传父
      this.keyword = val

      this.initHome()
    },
    resettable(val) {
      // 增加
      console.log(val);
          addFunApi(val).then(res => {
              console.log(res);
              if (res.code == 200) {
                 
                  this.arr = res.data
              }
          })

    },
    initHome() {
      var params = {
        keyword: this.keyword,
        page: this.page,
        pageSize: this.pageSize
      }
      getHomeApi(params).then((res)=> {
        console.log(2222222);
        console.log(res);
        if (res.code == 200) {
          this.arr = res.data
          this.total = res.total
        }
      })
    }
  },


}
</script>


<style lang="less">


</style>